﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.Geometry;

namespace hzGis.utils
{
    public class GeometryHelper
    {
        /// <summary>
        /// Envelope转Polygon
        /// </summary>
        /// <param name="envelope"></param>
        /// <returns></returns>
        public static IPolygon EnvelopeToPolygon(IEnvelope envelope)
        {
            IPointCollection pointColl = new Polygon();

            IPoint point = new Point();
            point.PutCoords(envelope.XMin, envelope.YMin);
            pointColl.AddPoint(point);

            point = new Point();
            point.PutCoords(envelope.XMax, envelope.YMin);
            pointColl.AddPoint(point);

            point = new Point();
            point.PutCoords(envelope.XMax, envelope.YMax);
            pointColl.AddPoint(point);

            point = new Point();
            point.PutCoords(envelope.XMin, envelope.YMax);
            pointColl.AddPoint(point);

            point = new Point();
            point.PutCoords(envelope.XMin, envelope.YMin);
            pointColl.AddPoint(point);

            return pointColl as IPolygon;
        }
    }
}
